package interfaces.options;

import interfaces.GUISource;

import org.fenggui.CheckBox;
import org.fenggui.event.ISelectionChangedListener;

import fileHandling.language.Lang;

public class CheckBoxOptionWidget extends OptionWidget {
	
	private CheckBox<String> checkBox;
	
	public CheckBoxOptionWidget(String initValue, Lang description) {
		super(description, initValue);
		checkBox = new CheckBox<String>();
		GUISource.setTheme(checkBox);
		changeValue(initValue);
		addWidget(checkBox);
	}
	
	public void addChangeListener(ISelectionChangedListener listener) {
		checkBox.addSelectionChangedListener(listener);
	}
	
	@Override
	public String getValue() { return checkBox.isSelected() + ""; }
	
	@Override
	public void setToHigh() { changeValue(true + ""); }
	
	@Override
	public void setToMedium() { changeValue(false + ""); }
	
	@Override
	public void setToLow() { changeValue(false + ""); }
	
	@Override
	public void changeValue(String value) { checkBox.setSelected(Boolean.valueOf(value).booleanValue()); }
}